package com.ics.web.controller.travelstar.controller;

import com.ics.common.annotation.Log;
import com.ics.common.core.controller.BaseController;
import com.ics.common.core.domain.AjaxResult;
import com.ics.common.enums.BusinessType;
import com.ics.web.controller.travelstar.domain.TbAboutUs;
import com.ics.web.controller.travelstar.dto.AboutUsDTO;
import com.ics.web.controller.travelstar.service.ITbAboutUsService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Arrays;

/**
 * 关于我们Controller
 *
 * @author ics
 * @date 2024-10-22
 */
@RestController
@RequestMapping("/tires/us")
public class TbAboutUsController extends BaseController {
    @Resource
    private ITbAboutUsService tbAboutUsService;

    /**
     * 查询关于我们列表
     */
    @ApiOperation("查询关于我们列表")
    @GetMapping("/list")
    public AjaxResult list(AboutUsDTO aboutUsDTO) {
        return success(tbAboutUsService.listPage(aboutUsDTO));
    }

    /**
     * 获取关于我们详细信息
     */
    @ApiOperation("获取关于我们详细信息")
    @GetMapping(value = "/getInfo/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(tbAboutUsService.getById(id));
    }

    /**
     * 新增关于我们
     */
    @ApiOperation("新增关于我们")
    @Log(title = "关于我们", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody TbAboutUs tbAboutUs) {
        return toAjax(tbAboutUsService.saveOrUpdate(tbAboutUs));
    }


    /**
     * 删除关于我们
     */
    @ApiOperation("删除关于我们")
    @Log(title = "关于我们", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    public AjaxResult remove(@RequestParam("ids") String ids) {
        return toAjax(tbAboutUsService.removeByIds(Arrays.asList(ids.split(","))));
    }

}
